home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / info / lispref.info-12 < prev    next >
Encoding:
GNU Info File  |  1995-09-01  |  50.4 KB  |  1,277 lines

  1. This is Info file ../../info/lispref.info, produced by Makeinfo-1.63
  2. from the input file lispref.texi.
  3.  
  4.    Edition History:
  5.  
  6.    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
  7. Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
  8. Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
  9. XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
  10. GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
  11. Programmer's Manual (for 19.13) Third Edition, July 1995
  12.  
  13.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
  14. Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
  15. Copyright (C) 1995 Amdahl Corporation.  Copyright (C) 1995 Ben Wing.
  16.  
  17.    Permission is granted to make and distribute verbatim copies of this
  18. manual provided the copyright notice and this permission notice are
  19. preserved on all copies.
  20.  
  21.    Permission is granted to copy and distribute modified versions of
  22. this manual under the conditions for verbatim copying, provided that the
  23. entire resulting derived work is distributed under the terms of a
  24. permission notice identical to this one.
  25.  
  26.    Permission is granted to copy and distribute translations of this
  27. manual into another language, under the above conditions for modified
  28. versions, except that this permission notice may be stated in a
  29. translation approved by the Foundation.
  30.  
  31.    Permission is granted to copy and distribute modified versions of
  32. this manual under the conditions for verbatim copying, provided also
  33. that the section entitled "GNU General Public License" is included
  34. exactly as in the original, and provided that the entire resulting
  35. derived work is distributed under the terms of a permission notice
  36. identical to this one.
  37.  
  38.    Permission is granted to copy and distribute translations of this
  39. manual into another language, under the above conditions for modified
  40. versions, except that the section entitled "GNU General Public License"
  41. may be included in a translation approved by the Free Software
  42. Foundation instead of in the original English.
  43.  
  44. 
  45. File: lispref.info,  Node: Excess Open,  Next: Excess Close,  Up: Syntax Errors
  46.  
  47. Excess Open Parentheses
  48. -----------------------
  49.  
  50.    The first step is to find the defun that is unbalanced.  If there is
  51. an excess open parenthesis, the way to do this is to insert a close
  52. parenthesis at the end of the file and type `C-M-b' (`backward-sexp').
  53. This will move you to the beginning of the defun that is unbalanced.
  54. (Then type `C-SPC C-_ C-u C-SPC' to set the mark there, undo the
  55. insertion of the close parenthesis, and finally return to the mark.)
  56.  
  57.    The next step is to determine precisely what is wrong.  There is no
  58. way to be sure of this except to study the program, but often the
  59. existing indentation is a clue to where the parentheses should have
  60. been.  The easiest way to use this clue is to reindent with `C-M-q' and
  61. see what moves.
  62.  
  63.    Before you do this, make sure the defun has enough close parentheses.
  64. Otherwise, `C-M-q' will get an error, or will reindent all the rest of
  65. the file until the end.  So move to the end of the defun and insert a
  66. close parenthesis there.  Don't use `C-M-e' to move there, since that
  67. too will fail to work until the defun is balanced.
  68.  
  69.    Now you can go to the beginning of the defun and type `C-M-q'.
  70. Usually all the lines from a certain point to the end of the function
  71. will shift to the right.  There is probably a missing close parenthesis,
  72. or a superfluous open parenthesis, near that point.  (However, don't
  73. assume this is true; study the code to make sure.)  Once you have found
  74. the discrepancy, undo the `C-M-q' with `C-_', since the old indentation
  75. is probably appropriate to the intended parentheses.
  76.  
  77.    After you think you have fixed the problem, use `C-M-q' again.  If
  78. the old indentation actually fit the intended nesting of parentheses,
  79. and you have put back those parentheses, `C-M-q' should not change
  80. anything.
  81.  
  82. 
  83. File: lispref.info,  Node: Excess Close,  Prev: Excess Open,  Up: Syntax Errors
  84.  
  85. Excess Close Parentheses
  86. ------------------------
  87.  
  88.    To deal with an excess close parenthesis, first insert an open
  89. parenthesis at the beginning of the file, back up over it, and type
  90. `C-M-f' to find the end of the unbalanced defun.  (Then type `C-SPC C-_
  91. C-u C-SPC' to set the mark there, undo the insertion of the open
  92. parenthesis, and finally return to the mark.)
  93.  
  94.    Then find the actual matching close parenthesis by typing `C-M-f' at
  95. the beginning of the defun.  This will leave you somewhere short of the
  96. place where the defun ought to end.  It is possible that you will find
  97. a spurious close parenthesis in that vicinity.
  98.  
  99.    If you don't see a problem at that point, the next thing to do is to
  100. type `C-M-q' at the beginning of the defun.  A range of lines will
  101. probably shift left; if so, the missing open parenthesis or spurious
  102. close parenthesis is probably near the first of those lines.  (However,
  103. don't assume this is true; study the code to make sure.)  Once you have
  104. found the discrepancy, undo the `C-M-q' with `C-_', since the old
  105. indentation is probably appropriate to the intended parentheses.
  106.  
  107.    After you think you have fixed the problem, use `C-M-q' again.  If
  108. the old indentation actually fit the intended nesting of parentheses,
  109. and you have put back those parentheses, `C-M-q' should not change
  110. anything.
  111.  
  112. 
  113. File: lispref.info,  Node: Compilation Errors,  Next: Edebug,  Prev: Syntax Errors,  Up: Debugging
  114.  
  115. Debugging Problems in Compilation
  116. =================================
  117.  
  118.    When an error happens during byte compilation, it is normally due to
  119. invalid syntax in the program you are compiling.  The compiler prints a
  120. suitable error message in the `*Compile-Log*' buffer, and then stops.
  121. The message may state a function name in which the error was found, or
  122. it may not.  Either way, here is how to find out where in the file the
  123. error occurred.
  124.  
  125.    What you should do is switch to the buffer ` *Compiler Input*'.
  126. (Note that the buffer name starts with a space, so it does not show up
  127. in `M-x list-buffers'.)  This buffer contains the program being
  128. compiled, and point shows how far the byte compiler was able to read.
  129.  
  130.    If the error was due to invalid Lisp syntax, point shows exactly
  131. where the invalid syntax was *detected*.  The cause of the error is not
  132. necessarily near by!  Use the techniques in the previous section to find
  133. the error.
  134.  
  135.    If the error was detected while compiling a form that had been read
  136. successfully, then point is located at the end of the form.  In this
  137. case, this technique can't localize the error precisely, but can still
  138. show you which function to check.
  139.  
  140. 
  141. File: lispref.info,  Node: Edebug,  Prev: Compilation Errors,  Up: Debugging
  142.  
  143. Edebug
  144. ======
  145.  
  146.    Edebug is a source-level debugger for XEmacs Lisp programs that
  147. provides the following features:
  148.  
  149.    * Step through evaluation, stopping before and after each expression.
  150.  
  151.    * Set conditional or unconditional breakpoints, install persistent
  152.      breakpoints, or a global break event.
  153.  
  154.    * Trace slow or fast stopping briefly at each stop point, or each
  155.      breakpoint.
  156.  
  157.    * Display expression results and evaluate expressions as if outside
  158.      of edebug.  Interface with the custom printing package for
  159.      printing circular structures.
  160.  
  161.    * Automatically reevaluate a list of expressions and display their
  162.      results each time Edebug updates the display.
  163.  
  164.    * Output trace info on function enter and exit.
  165.  
  166.    * Errors stop before the source causing the error.
  167.  
  168.    * Display backtrace without edebug calls.
  169.  
  170.    * Allow specification of argument evaluation for macros and defining
  171.      forms.
  172.  
  173.    * Provide rudimentary coverage testing and display of frequency
  174.      counts.
  175.  
  176.    The first three sections of this chapter should tell you enough about
  177. Edebug to enable you to use it.
  178.  
  179. * Menu:
  180.  
  181. * Using Edebug::        Introduction to use of Edebug.
  182. * Instrumenting::        You must first instrument code.
  183. * Edebug Execution Modes::    Execution modes, stopping more or less often.
  184. * Jumping::            Commands to jump to a specified place.
  185. * Edebug Misc::            Miscellaneous commands.
  186. * Breakpoints::            Setting breakpoints to make the program stop.
  187. * Views::            Viewing the outside buffer and window status.
  188. * Edebug Eval::            Evaluating expressions within Edebug.
  189. * Eval List::            Automatic expression evaluation.
  190. * Printing::            Printing circular structure in Edebug.
  191. * Coverage Testing::        How to test evaluation coverage.
  192. * The Outside Context::        Data that Edebug saves and restores.
  193. * Macro Calls::            Specifying how to handle macro calls.
  194. * Edebug Options::        Option variables for customizing Edebug.
  195.  
  196. 
  197. File: lispref.info,  Node: Using Edebug,  Next: Instrumenting,  Up: Edebug
  198.  
  199. Using Edebug
  200. ------------
  201.  
  202.    To debug a Emacs Lisp program with Edebug, you must first
  203. "instrument" the Lisp functions that you want to debug.  *Note
  204. Instrumenting::.
  205.  
  206.    Once a function is instrumented, any call to the function activates
  207. Edebug.  Activating Edebug may stop execution and let you step through
  208. the function, or it may update the display and continue execution while
  209. checking for debugging commands, depending on the selected Edebug
  210. execution mode.  The initial execution mode is `step', by default,
  211. which does stop execution.  *Note Edebug Execution Modes::.
  212.  
  213.    Within Edebug, you normally view an Emacs buffer showing the source
  214. of the Lisp function you are debugging.  We call this the "Edebug
  215. buffer"--but note that it is not always the same buffer, and it is not
  216. reserved for Edebug use.
  217.  
  218.    An arrow at the left margin indicates the line where the function is
  219. executing.  Point initially shows where within the line the function is
  220. executing, but this ceases to be true if you move point yourself.
  221.  
  222.    If you instrument the definition of `fac' (shown below) for Edebug
  223. and then execute `(fac 3)', here is what you normally see.  Point is at
  224. the open-parenthesis before `if'.
  225.  
  226.      (defun fac (n)
  227.      =>-!-(if (< 0 n)
  228.            (* n (fac (1- n)))
  229.          1))
  230.  
  231.    The places within a function where Edebug can stop execution are
  232. called "stop points".  These occur both before and after each
  233. subexpression that is a list, and also after each variable reference.
  234. Here we show with periods the stop points found in the function `fac':
  235.  
  236.      (defun fac (n)
  237.        .(if .(< 0 n.).
  238.            .(* n. .(fac (1- n.).).).
  239.          1).)
  240.  
  241.    While a buffer is the Edebug buffer, the special commands of Edebug
  242. are available in it, instead of many usual editing commands.  Type `?'
  243. to display a list of Edebug commands.  In particular, you can exit just
  244. the innermost Edebug activation level with `C-]', and you can return
  245. all the way to top level with `q'.
  246.  
  247.    For example, you can type the Edebug command SPC to execute until
  248. the next stop point.  If you type SPC once after entry to `fac', here
  249. is the state that you get:
  250.  
  251.      (defun fac (n)
  252.      =>(if -!-(< 0 n)
  253.            (* n (fac (1- n)))
  254.          1))
  255.  
  256.    When Edebug stops execution after an expression, it displays the
  257. expression's value in the echo area.  Use the `r' command to display
  258. the value again later.
  259.  
  260.    If no instrumented code is currently being executed, `debug' is run
  261. normally.  But while Edebug is active, it catches all errors (if
  262. `debug-on-error' is non-`nil') and quits (if `debug-on-quit' is
  263. non-`nil').  When this happens, Edebug displays the last stop point
  264. that it knows about.  This may be the location of a call to a function
  265. which was not instrumented, within which the error actually occurred.
  266. Note that you can also get a full backtrace inside of Edebug (see *Note
  267. Edebug Misc::).
  268.  
  269. 
  270. File: lispref.info,  Node: Instrumenting,  Next: Edebug Execution Modes,  Prev: Using Edebug,  Up: Edebug
  271.  
  272. Instrumenting for Edebug
  273. ------------------------
  274.  
  275.    In order to use Edebug to debug Lisp code, you must first
  276. "instrument" the code.  Instrumenting a form inserts additional code
  277. into it which invokes Edebug at the proper places.  When instrumenting
  278. any kind of definition (not just `defun' or `defmacro'), only the
  279. executable expressions inside of the definition are instrumented.  If
  280. any syntax error is found while instrumenting, point is left at the
  281. error and an `invalid-read-syntax' error is signaled.
  282.  
  283.    Edebug knows how to instrument all the standard special forms,
  284. interactive forms with or without expression arguments, anonymous lambda
  285. expressions, and other defining forms.  It cannot know what a
  286. user-defined macro will do with the arguments of a macro call so you
  287. must tell it; *note Macro Calls::. for the details.
  288.  
  289.    Once you have loaded Edebug, the command `C-M-x' (`eval-defun') is
  290. redefined so that when used with a prefix argument on a definition, it
  291. instruments the definition.  If the variable `edebug-all-defs' is
  292. non-`nil', that inverts the meaning of the prefix argument: then
  293. `C-M-x' instruments the definition *unless* it has a prefix argument.
  294. The default value of `edebug-all-defs' is `nil'.  The command `M-x
  295. edebug-all-defs' toggles the value of the variable `edebug-all-defs'.
  296.  
  297.    If `edebug-all-defs' is non-`nil', then the commands `eval-region'
  298. and `eval-current-buffer' also instrument any definitions they
  299. evaluate.  Similarly, `edebug-all-forms' controls whether `eval-region'
  300. should instrument *any* form, even non-defining forms.  The command
  301. `M-x edebug-all-forms' toggles this option.
  302.  
  303.    Another command, `M-x edebug-eval-top-level-form', is available to
  304. instrument any top-level form regardless of the value of
  305. `edebug-all-defs'.  Additionally, this command will instrument
  306. top-level forms that are not definitions.
  307.  
  308.    Loading a file does not instrument expressions for Edebug.
  309. Evaluations in the minibuffer via `eval-expression' (`M-ESC') are never
  310. instrumented.
  311.  
  312.    To remove instrumentation from a definition, simply reevaluate it
  313. with one of the non-instrumenting commands that evaluate definitions, or
  314. reload the file.
  315.  
  316.    See *Note Edebug Eval:: for discussion of other evaluation functions
  317. available inside of Edebug.
  318.  
  319. 
  320. File: lispref.info,  Node: Edebug Execution Modes,  Next: Jumping,  Prev: Instrumenting,  Up: Edebug
  321.  
  322. Edebug Execution Modes
  323. ----------------------
  324.  
  325.    Edebug supports several execution modes for running the program you
  326. are debugging.  We call these alternatives "Edebug execution modes"; do
  327. not confuse them with major modes or minor modes.  The current Edebug
  328. execution mode determines how Edebug displays the progress of the
  329. evaluation, whether it stops at each stop point, or continues to the
  330. next breakpoint, for example.
  331.  
  332.    Normally, you specify the Edebug execution mode by typing a command
  333. to continue the program in a certain mode.  Here is a table of these
  334. commands.  All except for `S' resume execution of the program, at least
  335. for a certain distance.
  336.  
  337. `S'
  338.      Stop: don't execute any more of the program for now, just wait for
  339.      more Edebug commands.  (`edebug-stop')
  340.  
  341. `SPC'
  342.      Step: stop at the next stop point encountered. (`edebug-step-mode')
  343.  
  344. `n'
  345.      Next: stop at the next stop point encountered after an expression.
  346.      Also see `edebug-forward-sexp' in *Note Edebug Misc::.
  347.      (`edebug-next-mode')
  348.  
  349. `t'
  350.      Trace: pause one second at each Edebug stop point.
  351.      (`edebug-trace-mode')
  352.  
  353. `T'
  354.      Rapid trace: update at each stop point, but don't actually pause.
  355.      (`edebug-Trace-fast-mode')
  356.  
  357. `g'
  358.      Go: run until the next breakpoint.  *Note Breakpoints::.
  359.      (`edebug-go-mode')
  360.  
  361. `c'
  362.      Continue: pause for one second at each breakpoint, but don't stop.
  363.      (`edebug-continue-mode')
  364.  
  365. `C'
  366.      Rapid continue: update at each breakpoint, but don't actually
  367.      pause.  (`edebug-Continue-fast-mode')
  368.  
  369. `G'
  370.      Go non-stop: ignore breakpoints.  You can still stop the program
  371.      by typing `S'. (`edebug-Go-nonstop-mode')
  372.  
  373.    In general, the execution modes earlier in the above list run the
  374. program more slowly or stop sooner.
  375.  
  376.    When you enter a new Edebug level, the mode comes from the value of
  377. the variable `edebug-initial-mode'.  By default, this specifies "step"
  378. mode.  If the mode thus specified does not stop, then the Edebug level
  379. executes the program (or part of it).
  380.  
  381.    While executing or tracing, you can interrupt the execution by typing
  382. any Edebug command.  Edebug stops the program at the next stop point and
  383. then executes the command that you typed.  For example, typing `t'
  384. during execution switches to trace mode at the next stop point.
  385.  
  386.    You can use the `S' command to stop execution without doing anything
  387. else.
  388.  
  389.    If your function happens to read input, a character you hit
  390. intending to interrupt execution may be read by the function instead.
  391. You can avoid such unintended results by paying attention to when your
  392. program wants input.
  393.  
  394.    Keyboard macros containing the commands in this section do not
  395. completely work: exiting from Edebug, to resume the program, loses
  396. track of the keyboard macro.  This is not easy to fix.
  397.  
  398. 
  399. File: lispref.info,  Node: Jumping,  Next: Edebug Misc,  Prev: Edebug Execution Modes,  Up: Edebug
  400.  
  401. Jumping
  402. -------
  403.  
  404.    Commands described here let you jump to a specified location.  All,
  405. except `i', use temporary breakpoints to establish the stop point and
  406. then switch to `go' mode.  Any other breakpoint reached before the
  407. intended stop point will also stop execution.  See *Note Breakpoints::
  408. for the details on breakpoints.
  409.  
  410. `f'
  411.      Run the program forward over one expression.  More precisely, set a
  412.      temporary breakpoint at the position that `C-M-f' would reach,
  413.      then execute in `go' mode so that the program will stop at
  414.      breakpoints.
  415.  
  416.      With a prefix argument N, the temporary breakpoint is placed N
  417.      sexps beyond point.  If the containing list ends before N more
  418.      elements, then the place to stop is after the containing
  419.      expression.
  420.  
  421.      Be careful that the position `C-M-f' finds is a place that the
  422.      program will really get to; this may not be true in a
  423.      `condition-case', for example.
  424.  
  425.      This command does `forward-sexp' starting at point rather than the
  426.      stop point, thus providing more flexibility.  If you want to
  427.      execute one expression from the current stop point, type `w'
  428.      first, to move point there.
  429.  
  430.      (`edebug-forward-sexp')
  431.  
  432. `o'
  433.      Continue "out of" an expression.  It places a temporary breakpoint
  434.      at the end of the sexp containing point.  If the containing sexp
  435.      is the definition itself, it continues until just before the
  436.      returns.  If that is where you are now, it returns from the
  437.      function and then stops.
  438.  
  439.      In other words, this command does not exit the currently executing
  440.      definition unless you are positioned after the last sexp.
  441.  
  442.      (`edebug-step-out')
  443.  
  444. `i'
  445.      Step into the definition of the function or macro about to be
  446.      called, whether or not it has been instrumented.  If its location
  447.      is not known to Edebug, this command cannot be used.  After
  448.      loading Edebug, `eval-region' records the position of every
  449.      definition it evaluates, even if not instrumented.
  450.  
  451.      Use this command when stopped before the call, since otherwise it
  452.      is too late.
  453.  
  454.      This command does not switch to `go' mode; instead you must execute
  455.      the arguments before stepping into the function manually.  (A
  456.      future version will probably do as expected: set a temporary
  457.      breakpoint on the first expression in the function and switch to
  458.      `go' mode.)
  459.  
  460.      Although the automatic instrumentation is convenient, one
  461.      undesirable side effect of using `edebug-step-in' is that it
  462.      doesn't later uninstrument the stepped-into function.
  463.  
  464. `h'
  465.      Proceed to the stop point near where point is using a temporary
  466.      breakpoint.
  467.  
  468.      (`edebug-goto-here')
  469.  
  470.    All the commands in this section may fail to work as expected in case
  471. of nonlocal exit, because a nonlocal exit can bypass the temporary
  472. breakpoint where you expected the program to stop.
  473.  
  474. 
  475. File: lispref.info,  Node: Edebug Misc,  Next: Breakpoints,  Prev: Jumping,  Up: Edebug
  476.  
  477. Miscellaneous
  478. -------------
  479.  
  480.    Some miscellaneous commands are described here.
  481.  
  482. `?'
  483.      Display the help message for Edebug.  (`edebug-help')
  484.  
  485. `C-]'
  486.      Abort one level back to the previous command level.
  487.      (`abort-recursive-edit')
  488.  
  489. `q'
  490.      Return to the top level editor command loop.  This exits all
  491.      recursive editing levels, including all levels of Edebug activity.
  492.      However, instrumented code protected with `unwind-protect' or
  493.      `condition-case' forms may resume debugging.  (`top-level')
  494.  
  495. `Q'
  496.      Like `q' but don't stop even for protected code.
  497.      (`top-level-nonstop')
  498.  
  499. `r'
  500.      Redisplay the most recently known expression result in the echo
  501.      area.  (`edebug-previous-result')
  502.  
  503. `d'
  504.      Display a backtrace, excluding Edebug's own functions for clarity.
  505.  
  506.      You cannot use debugger commands in the backtrace buffer in Edebug
  507.      as you would in the standard debugger.
  508.  
  509.      The backtrace buffer is killed automatically when you continue
  510.      execution.
  511.  
  512.    From the Edebug recursive edit, you may invoke commands that activate
  513. Edebug again recursively.  Any time Edebug is active, you can quit to
  514. the top level with `q' or abort one recursive edit level with `C-]'.
  515. You can display a backtrace of all the currently active function and
  516. macro calls with `d'.
  517.  
  518. 
  519. File: lispref.info,  Node: Breakpoints,  Next: Views,  Prev: Edebug Misc,  Up: Edebug
  520.  
  521. Breakpoints
  522. -----------
  523.  
  524.    Three more ways to stop execution once it has started are:
  525. breakpoints, the global break condition, and persistent breakpoints.
  526.  
  527.    While using Edebug, you can specify "breakpoints" in the program you
  528. are testing: points where execution should stop.  You can set a
  529. breakpoint at any stop point, as defined in *Note Using Edebug::.  For
  530. setting and unsetting breakpoints, the stop point that is affected is
  531. the first one at or after point in the Edebug buffer.  Here are the
  532. Edebug commands for breakpoints:
  533.  
  534. `b'
  535.      Set a breakpoint at the stop point at or after point.  If you use a
  536.      prefix argument, the breakpoint is temporary (it turns off the
  537.      first time it stops the program). (`edebug-set-breakpoint')
  538.  
  539. `u'
  540.      Unset the breakpoint (if any) at the stop point at or after the
  541.      current point. (`edebug-unset-breakpoint')
  542.  
  543. `x CONDITION RET'
  544.      Set a conditional breakpoint which stops the program only if
  545.      CONDITION evaluates to a non-`nil' value.  If you use a prefix
  546.      argument, the breakpoint is temporary (it turns off the first time
  547.      it stops the program). (`edebug-set-conditional-breakpoint')
  548.  
  549. `B'
  550.      Move point to the next breakpoint in the current definition.
  551.      (`edebug-next-breakpoint')
  552.  
  553.    While in Edebug, you can set a breakpoint with `b' and unset one
  554. with `u'.  First you must move point to a position at or before the
  555. desired Edebug stop point, then hit the key to change the breakpoint.
  556. Unsetting a breakpoint that has not been set does nothing.
  557.  
  558.    Reinstrumenting a definition clears all its breakpoints.
  559.  
  560.    A "conditional breakpoint" tests a condition each time the program
  561. gets there, to decide whether to stop.  To set a conditional breakpoint,
  562. use `x', and specify the condition expression in the minibuffer.
  563. Setting a conditional breakpoint again will put the previously entered
  564. expression in the minibuffer.
  565.  
  566.    You can make both conditional and unconditional breakpoints
  567. "temporary" by using a prefix arg to the command to set the breakpoint.
  568. After breaking at a temporary breakpoint, it is automatically cleared.
  569.  
  570.    Edebug always stops or pauses at a breakpoint except when the Edebug
  571. mode is Go-nonstop.  In that mode, it ignores breakpoints entirely.
  572.  
  573.    To find out where your breakpoints are, use the `B' command, which
  574. moves point to the next breakpoint in the definition following point, or
  575. to the first breakpoint if there are no following breakpoints.  This
  576. command does not continue execution--it just moves point in the buffer.
  577.  
  578. * Menu:
  579.  
  580. * Global Break Condition::    Breaking on an event.
  581. * Persistent Breakpoints::    Embedding breakpoints in code.
  582.  
  583. 
  584. File: lispref.info,  Node: Global Break Condition,  Next: Persistent Breakpoints,  Up: Breakpoints
  585.  
  586. Global Break Condition
  587. ......................
  588.  
  589.    In contrast to breaking when execution reaches specified locations,
  590. you can also cause a break when a certain event occurs.  The "global
  591. break condition" is a condition that is repeatedly evaluated at every
  592. stop point.  If it evaluates to a non-`nil' value, then execution is
  593. stopped or paused depending on the execution mode, just like a
  594. breakpoint.  Any errors that might occur as a result of evaluating the
  595. condition are ignored, as if the result were `nil'.
  596.  
  597.    You can set or edit the condition expression, stored in
  598. `edebug-global-break-condition', using `X'
  599. (`edebug-set-global-break-condition').
  600.  
  601.    Using the global break condition is perhaps the fastest way to find
  602. where in your code some event occurs, but since it is rather expensive
  603. you should reset the condition to `nil' when not in use.
  604.  
  605. 
  606. File: lispref.info,  Node: Persistent Breakpoints,  Prev: Global Break Condition,  Up: Breakpoints
  607.  
  608. Persistent Breakpoints
  609. ......................
  610.  
  611.    Since all breakpoints in a definition are cleared each time you
  612. reinstrument it, you might rather install a "persistent breakpoint"
  613. which is simply a call to the function `edebug'.  You can, of course,
  614. make such a call conditional.  For example, in the `fac' function,
  615. insert the first line as shown below to stop when the argument reaches
  616. zero:
  617.  
  618.      (defun fac (n)
  619.        (if (= n 0) (edebug))
  620.        (if (< 0 n)
  621.            (* n (fac (1- n)))
  622.          1))
  623.  
  624.    When the `fac' definition is instrumented and the function is called,
  625. edebug will cause a break before the call to `edebug'.  Depending on
  626. the execution mode, edebug will stop or pause.
  627.  
  628.    However, if no instrumented code is being executed, calling `edebug'
  629. will instead invoke `debug'.
  630.  
  631. 
  632. File: lispref.info,  Node: Views,  Next: Edebug Eval,  Prev: Breakpoints,  Up: Edebug
  633.  
  634. Views
  635. -----
  636.  
  637.    These Edebug commands let you view aspects of the buffer and window
  638. status that obtained before entry to Edebug.
  639.  
  640. `v'
  641.      View the outside window configuration. (`edebug-view-outside')
  642.  
  643. `p'
  644.      Temporarily display the outside current buffer with point at its
  645.      outside position. If prefix arg is supplied, sit for that many
  646.      seconds instead.  (`edebug-bounce-point')
  647.  
  648. `w'
  649.      Switch back to the buffer showing the currently executing
  650.      function, and move point back to the current stop point.
  651.      (`edebug-where')
  652.  
  653. `W'
  654.      Toggle the `edebug-save-windows' variable which indicates whether
  655.      the outside window configuration is saved and restored.  Also,
  656.      each time it is toggled on, make the outside window configuration
  657.      the same as the current window configuration.
  658.      (`edebug-toggle-save-windows')
  659.  
  660.    You can view the outside window configuration with `v' or just
  661. bounce to the current point in the current buffer with `p', even if it
  662. is not normally displayed.  After moving point, you may wish to pop
  663. back to the stop point with `w' from the Edebug buffer.
  664.  
  665.    By using the `W' command twice, Edebug again saves and restores the
  666. outside window configuration, but to the current configuration.  This is
  667. a convenient way to, for example, add another buffer to be displayed
  668. whenever Edebug is active.  However, the automatic redisplay of
  669. `*edebug*' and `*edebug-trace*' may conflict with the buffers you wish
  670. to see unless you have enough windows open.
  671.  
  672. 
  673. File: lispref.info,  Node: Edebug Eval,  Next: Eval List,  Prev: Views,  Up: Edebug
  674.  
  675. Evaluation
  676. ----------
  677.  
  678.    While within Edebug, you can evaluate expressions "as if" Edebug were
  679. not running.  Edebug tries to be invisible to the expression's
  680. evaluation and printing.  See *Note The Outside Context:: for details on
  681. this process.  Also see *Note Printing:: for how to control printing.
  682.  
  683. `e EXP RET'
  684.      Evaluate expression EXP in the context outside of Edebug.  That
  685.      is, Edebug tries to avoid altering the effect of EXP.
  686.      (`edebug-eval-expression')
  687.  
  688. `M-ESC EXP RET'
  689.      Evaluate expression EXP in the context of Edebug itself.
  690.  
  691. `C-x C-e'
  692.      Evaluate the expression before point, in the context outside of
  693.      Edebug.  (`edebug-eval-last-sexp')
  694.  
  695. 
  696. File: lispref.info,  Node: Eval List,  Next: Printing,  Prev: Edebug Eval,  Up: Edebug
  697.  
  698. Evaluation List Buffer
  699. ----------------------
  700.  
  701.    You can use the "evaluation list buffer", called `*edebug*', to
  702. evaluate expressions interactively.  You can also set up the
  703. "evaluation list" of expressions to be evaluated automatically each
  704. time Edebug updates the display.
  705.  
  706. `E'
  707.      Switch to the evaluation list buffer `*edebug*'.
  708.      (`edebug-visit-eval-list')
  709.  
  710.    In the `*edebug*' buffer you can use the commands of Lisp
  711. Interaction as well as these special commands:
  712.  
  713. `LFD'
  714.      Evaluate the expression before point, in the context outside of
  715.      Edebug, and insert the value in the buffer.
  716.      (`edebug-eval-print-last-sexp')
  717.  
  718. `C-x C-e'
  719.      Evaluate the expression before point, in the context outside of
  720.      Edebug.  (`edebug-eval-last-sexp')
  721.  
  722. `C-c C-u'
  723.      Build a new evaluation list from the first expression of each
  724.      group, reevaluate and redisplay.  Groups are separated by comment
  725.      lines.  (`edebug-update-eval-list')
  726.  
  727. `C-c C-d'
  728.      Delete the evaluation list group that point is in.
  729.      (`edebug-delete-eval-item')
  730.  
  731. `C-c C-w'
  732.      Switch back to the Edebug buffer at the current stop point.
  733.      (`edebug-where')
  734.  
  735.    You can evaluate expressions in the evaluation list window with
  736. `LFD' or `C-x C-e', just as you would in `*scratch*'; but they are
  737. evaluated in the context outside of Edebug.
  738.  
  739.    The expressions you enter interactively (and their results) are lost
  740. when you continue execution unless you add them to the evaluation list
  741. with `C-c C-u'.  This command builds a new list from the first
  742. expression of each "evaluation list group".  Groups are separated by
  743. comment lines.  Be careful not to add expressions that execute
  744. instrumented code otherwise an infinite loop will result.
  745.  
  746.    When the evaluation list is redisplayed, each expression is displayed
  747. followed by the result of evaluating it, and a comment line.  If an
  748. error occurs during an evaluation, the error message is displayed in a
  749. string as if it were the result.  Therefore expressions that use
  750. variables not currently valid, for example, do not interrupt your
  751. debugging.
  752.  
  753.    Here is an example of what the evaluation list window looks like
  754. after several expressions have been added to it:
  755.  
  756.      (current-buffer)
  757.      #<buffer *scratch*>
  758.      ;---------------------------------------------------------------
  759.      (selected-window)
  760.      #<window 16 on *scratch*>
  761.      ;---------------------------------------------------------------
  762.      (point)
  763.      196
  764.      ;---------------------------------------------------------------
  765.      bad-var
  766.      "Symbol's value as variable is void: bad-var"
  767.      ;---------------------------------------------------------------
  768.      (recursion-depth)
  769.      0
  770.      ;---------------------------------------------------------------
  771.      this-command
  772.      eval-last-sexp
  773.      ;---------------------------------------------------------------
  774.  
  775.    To delete a group, move point into it and type `C-c C-d', or simply
  776. delete the text for the group and update the evaluation list with `C-c
  777. C-u'.  When you add a new group, be sure it is separated from its
  778. neighbors by a comment line.
  779.  
  780.    After selecting `*edebug*', you can return to the source code buffer
  781. (the Edebug buffer) with `C-c C-w'.  The `*edebug*' buffer is killed
  782. when you continue execution, and recreated next time it is needed.
  783.  
  784. 
  785. File: lispref.info,  Node: Printing,  Next: Coverage Testing,  Prev: Eval List,  Up: Edebug
  786.  
  787. Printing
  788. --------
  789.  
  790.    If some structures that may be printed contain circular references to
  791. other parts of the same structure, you can print them more usefully with
  792. the `cust-print' package.
  793.  
  794.    To load the package and activate custom printing only for Edebug,
  795. simply use the command `edebug-install-custom-print-funcs'.  To restore
  796. the standard print functions, use `edebug-uninstall-custom-print-funcs'.
  797.  
  798.    While printing results, edebug binds `print-length', `print-level',
  799. and `print-circle' to `edebug-print-length' (`50'), `edebug-print-level'
  800. (`50'), and `edebug-print-circle' (`t') respectively, if these values
  801. are non-`nil'.
  802.  
  803.    Here is an example of circular structure printing.  An error will
  804. still be generated when `format' executes.
  805.  
  806.      (progn
  807.        (edebug-install-custom-print-funcs)
  808.        (setq a '(1 2))
  809.        (format "%s" (setcar a a)))
  810.  
  811. 
  812. File: lispref.info,  Node: Coverage Testing,  Next: The Outside Context,  Prev: Printing,  Up: Edebug
  813.  
  814. Coverage Testing
  815. ----------------
  816.  
  817.    Edebug provides a rudimentary coverage tester and frequency of
  818. execution display.  Frequency counts are always accumulated, both
  819. before and after evaluation of each instrumented expression, even if
  820. the execution mode is Go-nonstop.  Coverage testing is only done if the
  821. option `edebug-test-coverage' is non-`nil' because this is relatively
  822. expensive.  Both data sets are displayed by `edebug-display-freq-count'.
  823.  
  824.  - Function: edebug-display-freq-count
  825.      Display the frequency count data for each line of the current
  826.      definition.  The frequency counts are inserted as comment lines
  827.      after each line, and you can undo all insertions with one `undo'
  828.      command.  The counts are inserted starting under the `(' before an
  829.      expression or the `)' after an expression, or on the last char of
  830.      a symbol.  The counts are only displayed when they differ from
  831.      previous counts on the same line.
  832.  
  833.      If coverage is being tested, whenever all known results of an
  834.      expression are `eq', the char `=' will be appended after the count
  835.      for that expression.  Note that this is always the case for an
  836.      expression only evaluated once.
  837.  
  838.      To clear the frequency count and coverage data for a definition,
  839.      reinstrument it.
  840.  
  841.  
  842.    For example, after evaluating `(fac 5)' with a persistent
  843. breakpoint, and setting `edebug-test-coverage' to `t', the frequency
  844. data is looks like this:
  845.  
  846.      (defun fac (n)
  847.        (if (= n 0) (edebug))
  848.      ;#6           1      0 =5
  849.        (if (< 0 n)
  850.      ;#5         =
  851.            (* n (fac (1- n)))
  852.      ;#    5               0
  853.          1))
  854.      ;#   0
  855.  
  856. 
  857. File: lispref.info,  Node: The Outside Context,  Next: Macro Calls,  Prev: Coverage Testing,  Up: Edebug
  858.  
  859. The Outside Context
  860. -------------------
  861.  
  862.    Edebug tries to be transparent to the program you are debugging.  In
  863. addition, most evaluations you do within Edebug (see *Note Edebug
  864. Eval::) occur in the same outside context which is temporarily restored
  865. for the evaluation.  But Edebug is not completely successful and this
  866. section explains precisely how it fails.
  867.  
  868. * Menu:
  869.  
  870. * Just Checking::        When Edebug decides what to do.
  871. * Outside Window Configuration::  When Edebug updates the display.
  872. * Edebug Recursive Edit::    When Edebug stops execution.
  873. * Side Effects::        How Edebug fails to be transparent.
  874.  
  875. 
  876. File: lispref.info,  Node: Just Checking,  Next: Outside Window Configuration,  Up: The Outside Context
  877.  
  878. Just Checking
  879. .............
  880.  
  881.    Whenever Edebug is entered just to think about whether to take some
  882. action, it needs to save and restore certain data.
  883.  
  884.    * `max-lisp-eval-depth' and `max-specpdl-size' are both incremented
  885.      so that your code should not be impacted by Edebug frames on the
  886.      stack.
  887.  
  888.    * The state of keyboard macro execution is saved and cleared out.
  889.  
  890. 
  891. File: lispref.info,  Node: Outside Window Configuration,  Next: Edebug Recursive Edit,  Prev: Just Checking,  Up: The Outside Context
  892.  
  893. Outside Window Configuration
  894. ............................
  895.  
  896.    When Edebug needs to display something (e.g., in trace mode), it
  897. saves the current window configuration from "outside" Edebug.  When you
  898. exit Edebug (by continuing the program), it restores the previous window
  899. configuration.
  900.  
  901.    XEmacs redisplays only when it pauses.  Usually, when you continue
  902. execution, the program comes back into Edebug at a breakpoint or after
  903. stepping, without pausing or reading input in between.  In such cases,
  904. XEmacs never gets a chance to redisplay the "outside" configuration.
  905. What you see is the window configuration for within Edebug, with no
  906. interruption.
  907.  
  908.    Entry to Edebug for displaying something also saves and restores the
  909. following data.  (Some of these variables are deliberately not restored
  910. if an error or quit signal occurs.)
  911.  
  912.    * The window configuration proper does not include which buffer is
  913.      current or where point and mark are in the current buffer, but
  914.      Edebug saves and restores these also.  However, the position of
  915.      point in the Edebug buffer is only saved and restored if the
  916.      outside current buffer is the same as the Edebug buffer.
  917.  
  918.    * The outside window configuration, is saved and restored if
  919.      `edebug-save-windows' is non-`nil'.  It is not restored on error
  920.      or quit, but the outside selected window is reselected even on
  921.      error or quit in case a `save-excursion' is active.  The window
  922.      start for the Edebug buffer is not restored, however.
  923.  
  924.    * The value of point in each displayed buffer is saved and restored
  925.      if `edebug-save-displayed-buffer-points' is non-`nil'.
  926.  
  927.    * The variables `overlay-arrow-position' and `overlay-arrow-string'
  928.      are saved and restored.  This permits recursive use of Edebug, and
  929.      use of Edebug while using GUD.
  930.  
  931.    * `cursor-in-echo-area' is locally bound to `nil' so that the cursor
  932.      shows up in the window.
  933.  
  934. 
  935. File: lispref.info,  Node: Edebug Recursive Edit,  Next: Side Effects,  Prev: Outside Window Configuration,  Up: The Outside Context
  936.  
  937. Edebug Recursive Edit
  938. .....................
  939.  
  940.    When Edebug is entered and actually reads commands from the user, it
  941. saves (and later restores) these additional data:
  942.  
  943.    * The current match data, for whichever buffer was current.
  944.  
  945.    * `last-command', `this-command', `last-command-char', and
  946.      `last-input-char'.  Commands used within Edebug do not affect these
  947.      variables outside of Edebug.
  948.  
  949.      But note that it is not possible to preserve the status reported by
  950.      `(this-command-keys)' and the variables `unread-command-char' and
  951.      `unread-command-event'.
  952.  
  953.    * `standard-output' and `standard-input'.
  954.  
  955. 
  956. File: lispref.info,  Node: Side Effects,  Prev: Edebug Recursive Edit,  Up: The Outside Context
  957.  
  958. Side Effects
  959. ............
  960.  
  961.    Edebug operation unavoidably alters some data in XEmacs, and this
  962. can interfere with debugging certain programs.
  963.  
  964.    * Lisp stack usage is increased, but the limits,
  965.      `max-lisp-eval-depth' and `max-specpdl-size', are also increased
  966.      proportionally.
  967.  
  968.    * The key sequence returned by `this-command-keys' is changed by
  969.      executing commands within Edebug and there is no way to reset the
  970.      key sequence from Lisp.
  971.  
  972.    * Edebug cannot save and restore the value of `unread-command-char'
  973.      or `unread-command-event'.  Entering Edebug while these variables
  974.      have nontrivial values can interfere with execution of the program
  975.      you are debugging.
  976.  
  977.    * Complex commands executed while in Edebug are added to the variable
  978.      `command-history'.  In rare cases this can alter execution.
  979.  
  980.    * Within Edebug, the recursion depth appears one deeper than the
  981.      recursion depth outside Edebug.  This is not true of the
  982.      automatically updated evaluation list window.
  983.  
  984.    * Horizontal scrolling of the Edebug buffer is not recovered.
  985.  
  986. 
  987. File: lispref.info,  Node: Macro Calls,  Next: Edebug Options,  Prev: The Outside Context,  Up: Edebug
  988.  
  989. Macro Calls
  990. -----------
  991.  
  992.    When Edebug instruments an expression that calls a Lisp macro, it
  993. needs additional advice to do the job properly.  This is because there
  994. is no way to tell which subexpressions of the macro call may be
  995. evaluated.  (Evaluation may occur explicitly in the macro body, or when
  996. the resulting expansion is evaluated, or any time later.)  You must
  997. explain the format of macro call arguments by using `def-edebug-spec' to
  998. define an "Edebug specification" for each macro.
  999.  
  1000.  - Macro: def-edebug-spec MACRO SPECIFICATION
  1001.      Specify which parts of a call to macro MACRO are subexpressions to
  1002.      be evaluated.  The second argument, SPECIFICATION, often looks like
  1003.      the formal macro argument list, but it specifies the structure of
  1004.      the macro call arguments.
  1005.  
  1006.      The MACRO argument may be any symbol, not just a macro name, as
  1007.      explained below.
  1008.  
  1009.    Here is a table of the possibilities for SPECIFICATION and how each
  1010. directs processing of arguments.
  1011.  
  1012. *`t'
  1013.      All arguments are instrumented for evaluation.
  1014.  
  1015. *`0'
  1016.      None of the arguments is instrumented.
  1017.  
  1018. *a symbol
  1019.      The symbol must have an Edebug specification which is used instead.
  1020.      This indirection is repeated until another kind of specification is
  1021.      found.  This allows you to inherit the specification for another
  1022.      macro.
  1023.  
  1024. *a list
  1025.      The elements of the list describe the types of the arguments of a
  1026.      calling form.  The possible elements of a specification list are
  1027.      described below.
  1028.  
  1029. * Menu:
  1030.  
  1031. * Specification List::        How to specify complex patterns of evaluation.
  1032. * Backtracking::        What Edebug does when matching fails.
  1033. * Specification Examples::
  1034.  
  1035. 
  1036. File: lispref.info,  Node: Specification List,  Next: Backtracking,  Up: Macro Calls
  1037.  
  1038. Specification List
  1039. ..................
  1040.  
  1041.    A "specification list" is required if some arguments of a macro call
  1042. are evaluated while others are not.  Some specification elements in a
  1043. specification list match one or more arguments, but others modify the
  1044. processing of all following specification elements.  The latter, called
  1045. "special specifications", are symbols beginning with ``&'' (e.g.
  1046. `&optional').
  1047.  
  1048.    A specification list may contain sublists which match arguments that
  1049. are themselves lists, or it may contain vectors used for grouping.
  1050. Sublists and groups thus subdivide the specification list into a
  1051. hierarchy of levels.  Special specifications only apply to the
  1052. remainder of the sublist or group they are contained in.  There is an
  1053. implicit grouping around each special specification and all following
  1054. elements in the sublist or group.
  1055.  
  1056.    If a specification list fails at some level, then backtracking may
  1057. be invoked to find some alternative at a higher level, or if no
  1058. alternatives remain, an error will be signaled.  See *Note
  1059. Backtracking:: for more details.
  1060.  
  1061.    Edebug specifications provide at least the power of regular
  1062. expression matching.  Additionally, some context free (i.e. finite
  1063. state with stack) constructs are supported: the matching of sublists
  1064. with balanced parentheses, recursive processing of forms, and indirect
  1065. specifications.
  1066.  
  1067.    Each element of a specification list may be one of the following,
  1068. with the corresponding type of argument:
  1069.  
  1070. `sexp'
  1071.      A single unevaluated expression.
  1072.  
  1073. `form'
  1074.      A single evaluated expression, which is instrumented.
  1075.  
  1076. `place'
  1077.      A place as in the Common Lisp `setf' place argument.  It will be
  1078.      instrumented just like a form, but the macro is expected to strip
  1079.      the instrumentation using `edebug-unwrap' or `edebug-unwrap*'.
  1080.  
  1081. `body'
  1082.      Short for `&rest form'.  See `&rest' below.
  1083.  
  1084. `function-form'
  1085.      A function form: a quoted function symbol, a quoted lambda
  1086.      expression, or a form (that should evaluate to a function symbol
  1087.      or lambda expression).  This is useful when function arguments
  1088.      might be quoted with `quote' rather than `function' since the body
  1089.      of a lambda expression will be instrumented either way.  See the
  1090.      `apply' example below.
  1091.  
  1092. `lambda-expr'
  1093.      An unquoted anonymous lambda expression.
  1094.  
  1095. `&optional'
  1096.      All following elements in the specification list are optional; as
  1097.      soon as one does not match, Edebug stops matching at this level.
  1098.      To make just one item optional, use `[&optional SPEC]'.  See the
  1099.      `defun' example below.
  1100.  
  1101. `&rest'
  1102.      All following elements in the specification list are repeated zero
  1103.      or more times.  All the elements need not be used in the last
  1104.      repetition, however.
  1105.  
  1106.      To specify repetition of certain types of arguments, followed by
  1107.      dissimilar arguments, use `[&rest SPECS...]'.  To specify all
  1108.      elements must match on the last repetition, use `&rest [SPECS...]'.
  1109.  
  1110. `&or'
  1111.      Each of the following elements in the specification list is an
  1112.      alternative, processed left to right until one matches.  One of the
  1113.      alternatives must match otherwise the `&or' specification fails.
  1114.      To group two or more list elements as a single alternative,
  1115.      enclose them in `[...]'.
  1116.  
  1117. `¬'
  1118.      Each of the following elements is matched as alternatives, and if
  1119.      any of them match, the specification fails.  If none of them
  1120.      match, nothing is matched, but the `¬' specification succeeds.
  1121.      See the `lambda-list' example below.
  1122.  
  1123. `&define'
  1124.      Indicates that the specification is for a defining form.  The
  1125.      defining form itself is not instrumented, but forms inside it may
  1126.      be.  The `&define' keyword must appear first in a top-level list
  1127.      specification.
  1128.  
  1129.      Other specifications that may only appear after `&define' are
  1130.      described here.  See the `defun' example below.
  1131.  
  1132.     `name'
  1133.           The argument, a symbol, is the name of the defining form.
  1134.           But a defining form need not be named at all in which case a
  1135.           unique name will be created for it.
  1136.  
  1137.           The `name' specification may be used more than once in the
  1138.           specification and each subsequent use will append the
  1139.           corresponding symbol argument to the previous name with ``@''
  1140.           between them.  This is useful for generating unique but
  1141.           meaningful names for definitions such as `defadvice' and
  1142.           `defmethod'.
  1143.  
  1144.     `:name'
  1145.           The specification following `:name' is used as an additional
  1146.           name component for the definition.  This is useful to add a
  1147.           unique component to the definition name.  It may be used more
  1148.           than once, and it does not affect matching of arguments.
  1149.  
  1150.     `arg'
  1151.           The argument, a symbol, is the name of an argument of the
  1152.           defining form.  However, lambda list keywords (symbols
  1153.           starting with ``&'') are not allowed.  See `lambda-list' and
  1154.           the example below.
  1155.  
  1156.     `lambda-list'
  1157.           This matches the whole argument list of an Emacs Lisp lambda
  1158.           expression, which is a list of symbols and the keywords
  1159.           `&optional' and `&rest'
  1160.  
  1161.     `def-body'
  1162.           The argument is the body of code in a definition.  This is
  1163.           like `body', described above, but a definition body must be
  1164.           instrumented with a special Edebug call.  Use `def-body' for
  1165.           the highest level list of forms within the definition.
  1166.  
  1167.     `def-form'
  1168.           The argument is a single top-level form in a definition.
  1169.           This is like `def-body', except use this to match a single
  1170.           form rather than a list of forms.  As a special case,
  1171.           `def-form' also means that tracing information is not output
  1172.           when the form is executed.  See the `interactive' example
  1173.           below.
  1174.  
  1175. `nil'
  1176.      This is successful when there are no more arguments to match;
  1177.      otherwise it fails.  See sublist specifications and the `backquote'
  1178.      example below.
  1179.  
  1180. `fence'
  1181.      No argument is matched but backtracking through the fence is
  1182.      disabled while matching the remainder of the specifications at
  1183.      this level.  See *Note Backtracking:: for more details.  Also see
  1184.      the `let' example below.
  1185.  
  1186. `OTHER-SYMBOL'
  1187.      Any other symbol in a specification list may be a predicate or an
  1188.      indirect specification.
  1189.  
  1190.      If the symbol has an Edebug specification, this "indirect
  1191.      specification" should be a list that is used in-line.  The
  1192.      specification may be defined with `def-edebug-spec' just as for
  1193.      macros. See the `defun' example below.
  1194.  
  1195.      Otherwise, the symbol should be a predicate.  The predicate is
  1196.      called with the argument and the specification fails if the
  1197.      predicate fails.  The argument is not instrumented.
  1198.  
  1199.      Predicates that may be used include: `symbolp', `integerp',
  1200.      `stringp', `vectorp', `atom' (which matches a number, string,
  1201.      symbol, or vector), `keywordp', and `lambda-list-keywordp'.  The
  1202.      last two, defined in `edebug.el', test whether the argument is a
  1203.      symbol starting with ``:'' and ``&'' respectively.
  1204.  
  1205. `[ELEMENTS...]'
  1206.      Rather than matching a vector argument, a vector treats the
  1207.      ELEMENTS as a single "group specification".
  1208.  
  1209. `"STRING"'
  1210.      A symbol named STRING.
  1211.  
  1212. `'SYMBOL or (quote SYMBOL)'
  1213.      The precise symbol SYMBOL, treated as unevaluated.  Use a string
  1214.      instead.
  1215.  
  1216. `(vector ELEMENTS...)'
  1217.      A vector whose elements must match the ELEMENTS in the
  1218.      specification.  See the `backquote' example below.
  1219.  
  1220. `(ELEMENTS...)'
  1221.      Any other list is a "sublist specification" and the argument must
  1222.      be a list whose elements match the specification ELEMENTS.
  1223.  
  1224.      A sublist specification may be a dotted list and the corresponding
  1225.      list argument may then be a dotted list.  Alternatively, the last
  1226.      cdr of a dotted list specification may be another sublist
  1227.      specification (via a grouping or an indirect specification) whose
  1228.      elements match the non-dotted list arguments.  This is useful in
  1229.      recursive specifications such as in the `backquote' example below.
  1230.      Also see the description of a `nil' specification above for
  1231.      terminating such recursion.
  1232.  
  1233.      Note that a sublist specification that is printed like `(specs .
  1234.      nil)' means the same as `(specs)', and `(specs .
  1235.      (sublist-elements...))' means the same as `(specs
  1236.      sublist-elements...)'.
  1237.  
  1238. 
  1239. File: lispref.info,  Node: Backtracking,  Next: Specification Examples,  Prev: Specification List,  Up: Macro Calls
  1240.  
  1241. Backtracking
  1242. ............
  1243.  
  1244.    If a specification fails to match at some point, this does not
  1245. necessarily mean a syntax error will be signaled; instead,
  1246. "backtracking" will take place until all alternatives have been
  1247. exhausted.  Eventually every element of the argument list must be
  1248. matched by some element in the specification, and every required element
  1249. in the specification must match some argument.
  1250.  
  1251.    The special specifications `&optional', `&rest', or `&or' establish
  1252. alternatives.
  1253.  
  1254.    Backtracking is disabled for the remainder of a sublist or group when
  1255. certain conditions occur, described below, and is reenabled when
  1256. another alternative is established.  You might want to disable
  1257. backtracking to commit to some alternative so that Edebug can provide
  1258. more specific syntax error messages.  Normally, if no alternative
  1259. matches, Edebug reports that none matched, but if one alternative is
  1260. committed to, Edebug can report how it failed to match.
  1261.  
  1262.    First, backtracking is disabled while matching any of the form
  1263. specifications (i.e. `form', `body', `def-form', and `def-body').
  1264. These specifications will match any form so any error must be in the
  1265. form itself rather than at a higher level.
  1266.  
  1267.    Second, backtracking is disabled after successfully matching a quoted
  1268. symbol or string specification.  If you have a set of alternative
  1269. constructs that all begin with the same symbol, you can usually work
  1270. around this limitation by factoring the symbol out of the alternatives,
  1271. e.g., `["foo" &or [first case] [second case] ...]'.
  1272.  
  1273.    Third, backtracking may be explicitly disabled by using the `fence'
  1274. specification.  This is useful when you know that there can be no
  1275. higher alternatives.
  1276.  
  1277.